print("请选择操作的类型:")
flag =1
while flag:
    print("1.注册|2.登录")
    type_input = int(input())
    if type_input ==1:
        user_name = input("请输入用户名:")
        user_password = input("请输入密码:")
        f_obj= open("./login.dic","a")
        f_obj.write(user_name+":"+user_password+"\n")
        f_obj.close()
    elif type_input ==2:
       i = 0
       j = 1
       # for i in range(4):
       while j:
           if i >=3:
               print("---------------------------------")
               print("输入次数过多!")
               flag=0
           else:
                user_name = input("请输入用户名:")
                user_password = input("请输入密码:")
                f_obj = open("./login.dic", "r")
                for line in f_obj:
                    '''
                    if (line != user_name+":"+user_password+"\n"):
                        print("用户名或密码错误!")
                        i +=1
                    else:
                        print(user_name+"welcome!")
                        flag = 0
                        j=0
                        '''
                    if (line == user_name+":"+user_password+"\n"):
                        print(user_name + "welcome!")
                        flag = 0
                        j = 0
                        break
                    else:
                        print("用户名或密码错误!")
                        i += 1




